package com.itheima.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

/**
 * @author 何景航
 * @date 2025/11/1 8:19
 */
//@WebFilter(urlPatterns = "/*")//拦截所有请求
@Slf4j
public class filterDemo implements Filter {


    @Override
    public void init(FilterConfig filterConfig) throws ServletException {
        log.info("init初始化");
    }

    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        log.info("拦截到了请求");
        filterChain.doFilter(servletRequest,servletResponse);
    }

    @Override
    public void destroy() {
        log.info("销毁");
    }
}
